Skip to content

fix state management and other issues#1

Closed
charlie-ashford wants to merge 1 commit into
SCToolsOrg:mainfrom
charlie-ashford:small-fixes
Closed

fix state management and other issues#1
charlie-ashford wants to merge 1 commit into
SCToolsOrg:mainfrom
charlie-ashford:small-fixes

Conversation

@charlie-ashford
Copy link
Copy Markdown

fixes

  • url doesnt update on typing anymore
  • proper state management between channels and videos
  • switching between channel/video keeps already loaded data in memory
  • channel and video inputs dont leak into each other anymore
  • stale api requests cant overwrite the current tab anymore
  • handles empty data, malformed data, missing api url, and api errors better
  • fixes mobile/responsive layout issues
  • improves chart layout

i wanted to use the tool, but got tired of all the dumb issues and bugs, so i fixed it

@netlify
Copy link
Copy Markdown

netlify Bot commented May 14, 2026

Deploy Preview for incomparable-custard-29a20c ready!

Name Link
🔨 Latest commit 86e90f0
🔍 Latest deploy log https://app.netlify.com/projects/incomparable-custard-29a20c/deploys/6a0586cb4520c50008ba461a
😎 Deploy Preview https://deploy-preview-1--incomparable-custard-29a20c.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread src/routes/+page.svelte
Comment on lines +862 to +873
{:else if activeResource.status === "loading"}
<p
class="rounded-md border bg-background/45 px-3 py-2 text-sm text-muted-foreground"
>
Loading {type} data...
</p>
{:else if activeResource.data.length === 0}
<p
class="rounded-md border bg-background/45 px-3 py-2 text-sm text-muted-foreground"
>
Enter a {type} ID to fetch charts and export CSVs.
</p>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really do not like this. this section should just be removed if there's no error.

Suggested change
{:else if activeResource.status === "loading"}
<p
class="rounded-md border bg-background/45 px-3 py-2 text-sm text-muted-foreground"
>
Loading {type} data...
</p>
{:else if activeResource.data.length === 0}
<p
class="rounded-md border bg-background/45 px-3 py-2 text-sm text-muted-foreground"
>
Enter a {type} ID to fetch charts and export CSVs.
</p>

Comment thread src/routes/+page.svelte
>
<Button
type="submit"
class="w-full lg:w-28"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this button is way too wide now

Suggested change
class="w-full lg:w-28"
class="w-full lg:w-24"

Comment thread src/routes/+page.svelte
autocomplete="off"
spellcheck="false"
placeholder={type === "channel"
? "UC_x5XG1OV2P6uZZ5FSM9Ttw"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we doing Google for Developers for this??

Suggested change
? "UC_x5XG1OV2P6uZZ5FSM9Ttw"
? "UCX6OQ3DkcsbYNE6H8uQQuVA"

Comment thread src/routes/+page.svelte
Comment on lines +726 to +732
<header class="flex flex-col gap-1">
<h1
class="text-2xl font-semibold tracking-normal text-foreground sm:text-3xl"
>
SCTools Data Exporter
</h1>
</header>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a reason why I didn't add a header to the website: it is cheesy af

Comment thread src/routes/+page.svelte
Comment on lines +418 to +422
$effect(() => {
if (source !== lastSource) {
lastSource = source;
resetAllLoadedData();
syncUrlToActiveType(type);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, this is why I used useSearchParams. this is just dealt with.

Comment thread src/routes/+page.svelte
>([]);
let lastSource = $state.raw<Source>("vidiq");
let lastType = $state.raw<ResourceType>("channel");
const requestControllers: Partial<Record<ResourceType, AbortController>> = {};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be a $state

Suggested change
const requestControllers: Partial<Record<ResourceType, AbortController>> = {};
const requestControllers = $state<Partial<Record<ResourceType, AbortController>>>({});

Comment thread src/routes/+page.svelte
<Label for="resource-id">{capitalize(type)} ID</Label>
<Input
id="resource-id"
bind:value={resources[type].draftId}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an unnecessary lookup for the resource. we already have a $derived variable for this

Suggested change
bind:value={resources[type].draftId}
bind:value={activeResource.draftId}

Comment thread src/routes/+layout.svelte

<svelte:head><link rel="icon" href={favicon} /></svelte:head>
<main class="p-6">
<main class="min-h-dvh px-3 py-4 sm:px-6 sm:py-6">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the padding needs to change when on different screen sizes

Comment thread src/routes/+page.svelte
Comment on lines +81 to +82
let lastSource = $state.raw<Source>("vidiq");
let lastType = $state.raw<ResourceType>("channel");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is type first before source on the current values, but source comes before type in the last values??

Suggested change
let lastSource = $state.raw<Source>("vidiq");
let lastType = $state.raw<ResourceType>("channel");
let lastType = $state.raw<ResourceType>("channel");
let lastSource = $state.raw<Source>("vidiq");

Comment thread src/routes/+page.svelte
import { env } from "$env/dynamic/public";
import { onMount } from "svelte";
import { z } from "zod";
import { useSearchParams } from "runed/kit";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not have been removed. I specifically chose to use this library because it lets us keep the url as the source of truth

@ToastedDev
Copy link
Copy Markdown
Member

either way, I'm closing this pr. I don't want this project/repo to have commits associated with you. please never contact me, gnz, anyone else at sctools, or the stats community ever again

@ToastedDev ToastedDev closed this Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants